import {
  ElMessage,
  ElMessageBox,
  ElMessageBoxOptions,
  MessageBoxData,
} from "element-plus";
import { RendererElement, RendererNode, VNode } from "vue";

export function ErrorMessage(msg: string) {
  ElMessage({
    message: msg,
    type: "error",
  });
}

export function SuccessMessage(msg: string) {
  ElMessage({
    message: msg,
    type: "success",
  });
}

export function AlertMessage(
  title: string,
  msg:
    | string
    | (() => VNode<RendererNode, RendererElement, { [key: string]: any }>),
  opts: ElMessageBoxOptions | undefined
): Promise<MessageBoxData> {
  return ElMessageBox.alert(msg, title, opts);
}

export function AlertPrompt(
  title: string,
  msg:
    | string
    | (() => VNode<RendererNode, RendererElement, { [key: string]: any }>),
  opts: ElMessageBoxOptions | undefined
): Promise<MessageBoxData> {
  return ElMessageBox.prompt(msg, title, opts);
}
